#include<iostream>
using namespace std;
class Matrix
{
	public:
		Matrix(int,int);
		~Matrix();
		int row,line;
		double *pointer;
		void setMatrix(double**);
		void print();
};
void Matrix::print()
{
	for(int i=0;i<row;i++)
	{
		for(int j=0;j<line;j++)
		{
			cout<<((double(*)[line])pointer)[i][j]<<" ";
		}
		cout<<endl;
	}
}
void Matrix::setMatrix(double **a)
{
	for(int i=0;i<this->row;i++)
	{
		for(int j=0;j<this->line;j++)
		{
			((double(*)[line])this->pointer)[i][j]=((double(*)[line])a)[i][j];
		}
	}
}
Matrix::Matrix(int row,int line)
{
	this->row=row;
	this->line=line;
	this->pointer=new double[row*line];
}
Matrix::~Matrix()
{
	delete[] this->pointer;
}
void Mul(Matrix m1,Matrix m2)
{
	if(m1.line!=m2.row)
	{
		cout<<"error"<<endl;
		return ;
	}
	double res[m1.row][m2.line];
	for(int i=0;i<m1.row;i++)
	{
		for(int j=0;j<m2.line;j++)
		{
			res[i][j]=0;
			for(int k=0;k<m1.line;k++)
			{
				res[i][j]+=((double(*)[m1.line])m1.pointer)[i][k]*((double(*)[m2.line])m2.pointer)[k][j];
			}
		}
	}
	for(int i=0;i<m1.row;i++)
	{
		for(int j=0;j<m2.line;j++)
		{
			cout<<res[i][j]<<" ";
		}
		cout<<endl;
	}
	return;
}
void Mul2(Matrix &m1,Matrix &m2)
{
	if(m1.line!=m2.row)
	{
		cout<<"error"<<endl;
		return ;
	}
	double res[m1.row][m2.line];
	for(int i=0;i<m1.row;i++)
	{
		for(int j=0;j<m2.line;j++)
		{
			res[i][j]=0;
			for(int k=0;k<m1.line;k++)
			{
				res[i][j]+=((double(*)[m1.line])m1.pointer)[i][k]*((double(*)[m2.line])m2.pointer)[k][j];
			}
		}
	}
	for(int i=0;i<m1.row;i++)
	{
		for(int j=0;j<m2.line;j++)
		{
			cout<<res[i][j]<<" ";
		}
		cout<<endl;
	}
	return;
}
void Mul(Matrix *m1,Matrix *m2)
{
	if(m1->line!=m2->row)
	{
		cout<<"error"<<endl;
		return ;
	}
	double res[m1->row][m2->line];
	for(int i=0;i<m1->row;i++)
	{
		for(int j=0;j<m2->line;j++)
		{
			res[i][j]=0;
			for(int k=0;k<m1->line;k++)
			{
				res[i][j]+=((double(*)[m1->line])m1->pointer)[i][k]*((double(*)[m2->line])m2->pointer)[k][j];
			}
		}
	}
	for(int i=0;i<m1->row;i++)
	{
		for(int j=0;j<m2->line;j++)
		{
			cout<<res[i][j]<<" ";
		}
		cout<<endl;
	}
	return;
}
int main()
{
	int x,y;
	cin>>x>>y;
	double a[x][y];
	for(int i=0;i<x;i++)
	{
		for(int j=0;j<y;j++)
		{
			cin>>a[i][j];
		}
	}
	Matrix m1(x,y);
	m1.setMatrix((double**)a);
	cin>>x>>y;
	double b[x][y];
	for(int i=0;i<x;i++)
	{
		for(int j=0;j<y;j++)
		{
			cin>>b[i][j];
		}
	}
	Matrix m2(x,y);
	m2.setMatrix((double**)b);
	Mul(m1,m2);
	Mul2(m1,m2);
	Mul(&m1,&m2);
	return 0;
}
